package pl.devfest.task;

import java.sql.SQLException;

import pl.devfest.GeneralActivity;
import pl.devfest.R;
import pl.devfest.model.Task;
import android.os.Bundle;
import android.widget.TextView;

public class TaskViewActivity extends GeneralActivity {

	public static final String EXTRA_TASK_ID = "task_id";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.task_details_activity);

		TextView type = (TextView) findViewById(R.id.type);
		TextView recipient = (TextView) findViewById(R.id.recipient);
		TextView adress = (TextView) findViewById(R.id.adress);
		TextView date = (TextView) findViewById(R.id.date);
		TextView message = (TextView) findViewById(R.id.message);

		String taskId = getIntent().getStringExtra(EXTRA_TASK_ID);

		try {
			Task task = getHelper().getTasksDao().queryForId(taskId);
			type.setText(task.getType());
			recipient.setText(task.getRecipient());
			adress.setText(task.getAddress());
			date.setText(task.getDate());
			message.setText(task.getMessage());

		} catch (SQLException e) {
			e.printStackTrace();
		}

	}
}
